<?php

// no direct access
defined('_JEXEC') or die('Restricted access');

// get parameter
$photo = $this->photo;

// create curl resource 
$ch = curl_init(); 

// set url 
curl_setopt($ch, CURLOPT_URL, $photo['photoURL']);

//return the transfer as a string 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

// get picture 
$picture = curl_exec($ch);

// close curl resource to free up system resources 
curl_close($ch);      

// clear output buffers
while (ob_get_level() > 0) ob_end_clean();

// we'll be outputting a file
header('Content-type: application/octet-stream');

// give filename
header('Content-Disposition: attachment; filename="'.$photo['photoTitle'].'"');

// send file
echo $picture;

// exit right now
exit();
?>
